import axios from 'axios'

// 添加菜品
export function addFood(data) {
  return axios.post('/api/foods', data)
}

// 获取菜品详情
export function getFood(id) {
  return axios.get(`/api/foods/${id}`)
}

// 更新菜品信息
export function updateFood(id, data) {
  return axios.put(`/api/foods/${id}`, data)
}

// 更新菜品状态
export function updateFoodStatus(id, status, merchantId) {
  return axios.put(`/api/foods/${id}/status?merchantId=${merchantId}&status=${status}`)
}

// 删除菜品
export function deleteFood(id, merchantId) {
  return axios.delete(`/api/foods/${id}?merchantId=${merchantId}`)
}

// 根据商家ID获取菜品列表
export function getFoodsByMerchant(merchantId, params) {
  return axios.get(`/api/foods/merchant/${merchantId}`, { params })
}

// 获取菜品列表（分页）
export function getFoodList(params) {
  return axios.get('/api/foods', { params })
}

// 根据分类获取菜品列表
export function getFoodsByCategory(category, merchantId) {
  return axios.get(`/api/foods/category/${category}/${merchantId}`)
}

// 获取热销菜品
export function getHotFoods(merchantId, limit) {
  return axios.get(`/api/foods/hot/${merchantId}${limit ? `?limit=${limit}` : ''}`)
}

// 批量获取菜品信息
export function batchGetFoods(ids) {
  return axios.post('/api/foods/batch', ids)
}

// 搜索菜品
export function searchFoods(params) {
  return axios.get('/api/foods/search', { params })
}

// 获取商家菜品分类列表
export function getMerchantFoodCategories(merchantId) {
  return axios.get(`/api/foods/categories/${merchantId}`)
}

// 获取商家菜品总数
export function getFoodCountByMerchant(merchantId, params) {
  return axios.get(`/api/foods/merchant/${merchantId}/count`, { params })
} 